import { ref } from 'vue';
import { useRouter } from 'vue-router';

import { defineStore } from 'pinia';

export const useBreadCrumbsStore = defineStore('BreadCrumbs', () => {
  const tabsList = ref([]);
  // 添加标签
  function addTabs(item) {
    // 判断item.key是否存在
    let key = item.key;
    const ind = tabsList.value.findIndex(it => it.key === key);
    if (ind === -1) {
      tabsList.value.push(item);
    }
  }
  // 删除标签
  function removeTabs(key) {
    tabsList.value = tabsList.value.filter(v => v.key !== key);
  }

  return { tabsList, addTabs, removeTabs };
});
